package main

import (
	"bytes"
	"encoding/json"
	"io/ioutil"
	"log"
	"net/http"
)

type sLogin struct {
	Username string
	Password string
}

func main() {

	s := &sLogin{}
	s.Username = "huangjian"
	s.Password = "123"

	b, err := json.Marshal(s)
	if err != nil {
		log.Panic("json marshal failed")
	}
	body := bytes.NewBuffer(b)

	url := "http://localhost:9090/jsonPostLogin"
	contentType := "application/json;charset=utf-8"
	res, err := http.Post(url, contentType, body)
	if err != nil {
		log.Panic("http post failed")
	}

	result, err := ioutil.ReadAll(res.Body)
	res.Body.Close()

	log.Println(result)
	log.Println(string(result))
}
